class Solution:
    def longestCommonPrefix(self, strs: List[str]) -> str:
        s0 = strs[0]
        for j, c in enumerate(s0):  # 从左到右
            for s in strs:  # 从上到下
                if j == len(s) or s[j] != c:  # 这一列有字母缺失或者不同
                    return s0[:j]  # 0 到 j-1 是公共前缀
        return s0

if __name__ == "__main__":
    strs = ["flower", "flow", "flight"]
    print(Solution().longestCommonPrefix(strs))

